package com.ruoyi.web.controller.memberManagement;

import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MemberOverview;
import com.ruoyi.system.service.IMemberOverviewService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 会员概览（存储会员统计周期内的汇总数据）Controller
 *
 * @author ruoyi
 * @date 2025-05-14
 */
@Api(tags="会员概览")
@RestController
@RequestMapping("/system/memberOverview")
public class MemberOverviewController extends BaseController
{
    @Autowired
    private IMemberOverviewService memberOverviewService;

    /**
     * 查询会员概览列表
     */
    @ApiOperation("查询会员概览")
    @PreAuthorize("@ss.hasPermi('system:overview:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberOverview memberOverview)
    {
        startPage();
        List<MemberOverview> list = memberOverviewService.selectMemberOverviewList(memberOverview);
        return getDataTable(list);
    }

    /**
     * 导出会员概览列表
     */
    @ApiOperation("导出会员概览")
    @PreAuthorize("@ss.hasPermi('system:overview:export')")
    @Log(title = "会员概览（存储会员统计周期内的汇总数据）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberOverview memberOverview)
    {
        List<MemberOverview> list = memberOverviewService.selectMemberOverviewList(memberOverview);
        ExcelUtil<MemberOverview> util = new ExcelUtil<MemberOverview>(MemberOverview.class);
        util.exportExcel(response, list, "会员概览（存储会员统计周期内的汇总数据）数据");
    }

    /**
     * 获取会员概览
     */
    @ApiOperation("获取会员概览")
    @PreAuthorize("@ss.hasPermi('system:overview:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(memberOverviewService.selectMemberOverviewById(id));
    }

    /**
     * 新增会员概览列表
     */
    @ApiOperation("新增会员概览")
    @PreAuthorize("@ss.hasPermi('system:overview:add')")
    @Log(title = "会员概览（存储会员统计周期内的汇总数据）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberOverview memberOverview)
    {
        return toAjax(memberOverviewService.insertMemberOverview(memberOverview));
    }

    /**
     * 修改会员概览列表
     */
    @ApiOperation("修改会员概览列表")
    @PreAuthorize("@ss.hasPermi('system:overview:edit')")
    @Log(title = "会员概览（存储会员统计周期内的汇总数据）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberOverview memberOverview)
    {
        return toAjax(memberOverviewService.updateMemberOverview(memberOverview));
    }

    /**
     * 删除会员概览列表
     */
    @ApiOperation("删除会员概览列表")
    @PreAuthorize("@ss.hasPermi('system:overview:remove')")
    @Log(title = "会员概览（存储会员统计周期内的汇总数据）", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(memberOverviewService.deleteMemberOverviewByIds(ids));
    }
}
